package com.example.transit.adapter;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.example.transit.ui.fragment.CollectionFragment;
import com.example.transit.ui.fragment.HistoryFragment;
import com.example.transit.ui.fragment.PlanFragment;

public class CouponVPAdapter extends FragmentPagerAdapter {
    private String[] titles = new String[]{"Collection", "Recent Used", "Route Plan"};
    private String type[] = {"0", "1", "2"};
    private Bundle bundle;

    public CouponVPAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int i) {
        Fragment fragment = null;
        bundle = new Bundle();
        bundle.putString("type", type[i]);
        switch (i) {
            case 0:
                fragment = new CollectionFragment();
                fragment.setArguments(bundle);
                break;
            case 1:
                fragment = new HistoryFragment();
                fragment.setArguments(bundle);
                break;
            case 2:
                fragment = new PlanFragment();
                fragment.setArguments(bundle);
                break;
            default:
                break;
        }
        return fragment;
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}